/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package logging.report.scribe;

import java.util.ArrayList;
import java.util.List;
import jcommon.transport.client.*;
import jcommon.transport.*;
import libCore.config.Config;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import logging.report.scribe.core.LogEntry;
import logging.report.scribe.core.ResultCode;
import logging.report.scribe.core.ScribeService;

/**
 *
 * @author LinhTA
 */
class LOG2 {

    public void log() {
        String host = Config.getParam("scribelog_service", "host");
        int port = Integer.parseInt(Config.getParam("scribelog_service", "port"));
        String category = "TEST_LINH";

        String mess = String.format(LogData.LOG_ACTION_TEMPLATE, "zingme", "login", "ccvv", "0001", "498568");
        LogEntry log_entry = new LogEntry(category, mess);
        TSocket socket = new TSocket(host, port);
        TTransport transport = new TFramedTransport(socket);
        TProtocol protocol = new TBinaryProtocol(transport, false, false);
        ScribeService.Client client = new ScribeService.Client(protocol, protocol);

        List<LogEntry> logs = new ArrayList<LogEntry>();
        logs.add(log_entry);

        try {
            transport.open();
            ResultCode result = client.Log(logs);
            System.out.print(result);
            transport.close();
        } catch (Exception e) {
            System.out.println(e);
        } finally {
            transport.close();
        }
    }

}
